classdef LaserData2 < handle
    %LaserData Organizes and plots data from an experiment using lasers
    %   Note: We always 'inherit' from 'handle'  using the syntax above
    
    properties
        X
        Y
        LaserOn
        FileName
    end
    
    methods
        %we could call this method 'plot', but we should not use the same
        %name as matlab's built-in functions.
        
        function plotData(obj) %first input must be 'obj'
            %note how we access the properties with 'obj'
            figure
            plot(obj.X,obj.Y,'o')
            xlabel('Optical Density')
            ylabel('PMT signal')
            
            if obj.LaserOn
                %we can make a string using variables similar to how we
                %used fprintf to print to command line.
                s=sprintf('%s : Laser on',obj.FileName)
            else
                s=sprintf('%s : Laser off',obj.FileName)
            end
            title(s)
   
        end
        
        %Here is a new function that uses input variable. 
        function out=AddVars(obj,A,B)
           obj.X
           out=A+B; 
           
           %we can call other methods from here using the syntax:
           obj.plotData()
           %plotData(obj) %alternate syntax (not recommended)
        end
        
    end
    
end



